package com.huang.consumer_mall.web;

import com.github.pagehelper.PageInfo;
import com.huang.consumer_mall.model.Commodity;
import com.huang.consumer_mall.model.PageCondition;
import com.huang.consumer_mall.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommodityController {

    @Autowired
    private CommodityService commodityService;



    @PostMapping("/api/customer/commodity/find")
    public PageInfo<Commodity> page(@RequestBody PageCondition<Commodity> condition){
        return commodityService.page(condition);
    }

    @PostMapping("/api/commodity/delete")
    public String  delete(@RequestBody Commodity commodity){
         commodityService.deleteById(commodity);
         return "success";
    }
    @PostMapping("/api/commodity/commodityAdd")
    public  String insert(@RequestBody Commodity commodity){
        commodityService.insert(commodity);
        return "success";
    }
    @PostMapping("/api/commodity/commodityUpdate")
    public String update(@RequestBody Commodity commodity){
        commodityService.update(commodity);
        return "success";
    }

    @PostMapping("/api/commodity/findDetail")
    public Commodity findDetail(@RequestBody Commodity commodity){
        return commodityService.findDetail(commodity);
    }

    @PostMapping("/api/customer/commodity/findDetail")
    public Commodity findDetail1(@RequestBody Commodity commodity){
        return commodityService.findDetail(commodity);
    }


}
